function searchDeviceId(){
	var id=null; id = (function(){
		try{
			return currentSelect.id, currentSelect.id;
		}catch(e){
			return null
		}
	})();
	if(id!=null)
		return id;
	id=getURLString("device_node_id");
	if(id!=null)
		return parseInt(id);
	return 0;
}

function serachUserId(){
	var id=null; id = (function(){var user_id; try{user_id = parseInt($("#user_id").text());}catch(e){user_id=null; return null;}
	if(!!user_id) return parseInt(user_id); else return null; })();
	if(id != null) return id;
	id=getURLString("user_id");
	if(id != null) return parseInt(id);
	return 1;

}

$(document).ready(function(){
	
	userID = serachUserId();
	deviceID = searchDeviceId();

	$("#link_to_device").attr("href", "/index/get_latest_monitor_data/?page_id=1&page_rows=20&user_id="+userID);
	$("#link_to_setting").attr("href", "/api/update_device_node/?device_node_id="+deviceID+"&user_id="+userID);
	$("#link_to_user_setting").attr("href","/index/create_user/?device_node_id="+deviceID+"&user_id="+userID);	
	// $("#link_to_user_setting").attr("href","/index/create_user");

	setAlarmLink();
	setHistoryLink();
});


setAlarmLink=function(){
	userID = serachUserId();
	deviceID = searchDeviceId();
	$("#link_to_alarm").attr("href", "/index/get_alarm_list/?rows=10&device_node_id="+deviceID+"&user_id="+userID);
}
setHistoryLink=function(){
	userID = serachUserId();
	deviceID = searchDeviceId();
	$("#link_to_history").attr("href", "/index/get_history_records?rows=10&device_node_id="+deviceID+"&user_id="+userID);
}
